<template>
  <div class="list" ref="wrapper">
    <div>
      <!-- 当前城市 -->
      <div class="area">
        <div class="title border-topbottom">当前城市</div>
        <div class="button-list">
          <div class="button-wrapper">
            <div class="button">北京</div>
          </div>
        </div>
      </div>
      <!-- 热门城市 -->
      <div class="area">
        <div class="title border-topbottom">热门城市</div>
        <div class="button-list">
          <div class="button-wrapper" v-for="item of hotCities" :key="item.id">
            <div class="button">{{item.name}}</div>
          </div>
        </div>
      </div>
      <!-- 字母开头 城市 -->
      <div class="area" v-for="(list, key) of cities" :key="key">
        <div class="title border-topbottom">{{key}}</div>
        <ul class="item-list" v-for="item of list" :key="item.index">
          <li class="item border-bottom">{{item.name}}</li>
        </ul>
        <!-- <div class="title border-topbottom">A</div>
        <ul class="item-list">
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
        </ul>
        <div class="title border-topbottom">A</div>
        <ul class="item-list">
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
        </ul>
        <div class="title border-topbottom">A</div>
        <ul class="item-list">
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
          <li class="item border-bottom">a</li>
        </ul> -->
      </div>
    </div>
  </div>
</template>

<script>
import BScroll from 'better-scroll'
export default {
  name: 'CityList',
  props: {
    hotCities: Array,
    cities: Object
  },
  mounted () { // 页面挂载后调用BScroll组件
    this.scroll = new BScroll(this.$refs.wrapper)
  }
}
</script>

<style lang="stylus" scoped>
  @import "~styles/varibles.styl"
  .border-topbottom
    &:before
      border-color: #ccc
    &:after
      border-color: #ccc
   .border-bottom
    &:before
      border-color: #cccccc
  .list // 引入BScroll组件前，先将页面禁止滚动
    overflow hidden
    position absolute
    top 1.58rem
    left 0
    right 0
    bottom 0
    .title
      line-height .54rem
      background #eee
      padding-left .2rem
      color #666
      font-size .26rem
    .button-list
      padding .1rem .6rem .1rem .1rem
      overflow hidden
      .button-wrapper
        float left
        width 33.33%
        .button
          padding .1rem 0
          margin .1rem
          text-align center
          border .02rem solid #ccc
          border-radius .06rem
    .item-list
      .item
        height .72rem
        line-height .72rem
        padding-left .2rem
</style>
